//
//  STInterface.m
//  Stock_Pro
//
//  Created by imuse on 11-1-27.
//  Copyright 2011 gaotime. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "STInterface.h"

#pragma mark 
#pragma mark STIOBJ
#pragma mark ====================

@interface STIObj : NSObject
{
	QUOTELV_SUBSCRIBE_ITEM* item;
}

-(void)setItem:(QUOTELV_SUBSCRIBE_ITEM*)p;
-(QUOTELV_SUBSCRIBE_ITEM*)getItem;

@end

@implementation STIObj

-(void)setItem:(QUOTELV_SUBSCRIBE_ITEM*)p
{
	item = p;
}

-(QUOTELV_SUBSCRIBE_ITEM*)getItem
{
	return item;
}

@end

#pragma mark 
#pragma mark STI
#pragma mark ====================

@interface STI : NSObject
{
	
}

+(STI*)shareSTIModel;

-(void)mainOnCallBack:(STIObj*)p;

@end

static STI *sti = nil;

@implementation STI

+(STI*)shareSTIModel
{
	@synchronized(self)
	{
		if (sti==nil) {
			sti = [[STI alloc] init];
		}
		return sti;
	}
}

-(void)mainOnCallBack:(STIObj*)p
{
	QUOTELV_SUBSCRIBE_ITEM* item;
	item = [p getItem];
	item->pResedData(item->pCBObj,item);
	//printf("\n aaa");
}

@end







void STInterface_resedData(QUOTELV_SUBSCRIBE_ITEM* item)
{
	//pSocket->pHttp->pResedData( pSocket->pHttp );
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	STI *p = [STI shareSTIModel];
	STIObj *pObj = [[STIObj alloc] init];
	[pObj setItem:item];
	[p performSelectorOnMainThread:@selector(mainOnCallBack:) withObject:pObj waitUntilDone:NO];
	[pObj release];
	[pool release];
}

